package cn.psvmc.cxzapi.controller.customer;

import cn.psvmc.cxzapi.model.common.GoodsEntity;
import cn.psvmc.cxzapi.model.common.MarketEntity;
import cn.psvmc.cxzapi.model.goods.TGoodsExample;
import cn.psvmc.cxzapi.response.*;
import cn.psvmc.cxzapi.service.customer.TCustomerHomeService;
import cn.psvmc.cxzapi.util.PageUtil;
import cn.psvmc.cxzapi.util.ToolUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author YWX
 * @Classname TCustomerHomeController
 * @Description 客户首页
 * @Date 2024/8/29 21:51
 **/
@RestController
@RequestMapping("/mpapi/customer_home")
public class TCustomerHomeController {

    @Resource
    private TCustomerHomeService customerHomeService;

    /**
     * @Description 营销首页表列表
     * @Date 2024/8/29 21:55
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_market")
    public Result listMarket(@RequestBody MarketEntity entity) {
        return ResultGenerator.genSuccessResult("查询成功！", customerHomeService.listMarket(entity));
    }

    /**
     * @Description 分类推荐组件实例列表
     * @Date 2024/8/29 21:58
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_component")
    public Result listComponent(@RequestBody MarketEntity entity) {
        return ResultGenerator.genSuccessResult("查询成功！", customerHomeService.listComponent(entity));
    }

    /**
     * @Description Banner 实例列表
     * @Date 2024/8/29 22:00
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_banner")
    public Result listBanner(@RequestBody MarketEntity entity) {
        ToolUtils.validation(new Object[]{entity.getComponentId(), "组件id", 2});
        return ResultGenerator.genSuccessResult("查询成功！", customerHomeService.listBanner(entity));
    }

    /**
     * @Description 1+2Banner 实例列表
     * @Date 2024/8/29 22:02
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_banner2")
    public Result listBanner2(@RequestBody MarketEntity entity) {
        ToolUtils.validation(new Object[]{entity.getComponentId(), "组件id", 2});
        return ResultGenerator.genSuccessResult("查询成功！", customerHomeService.listBanner2(entity));
    }

    /**
     * @Description 商品推荐实例列表
     * @Date 2024/8/29 22:07
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_example")
    public Result listExample(@RequestBody MarketEntity entity) {
        return ResultGenerator.genSuccessResult("查询成功！", customerHomeService.listExample(entity));
    }

    /**
     * @Description 根据标签查询商品列表
     * @Date 2024/9/1 18:13
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.PageResult2
     **/
    @PostMapping("/list_tags_goods")
    public PageResult2 listTagsGoods(@RequestBody GoodsEntity entity) {
        Page<TGoodsExample> queryPage = new Page<>(entity.getPage(), entity.getSize());
        return PageUtil.getPageResult2(customerHomeService.listTagsGoods(queryPage, entity));
    }

    /**
     * @Description 热门推荐商品列表
     * @Date 2024/10/2 20:20
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.PageResult2
     **/
    @PostMapping("/list_hot_goods")
    public PageResult2 listHotsGoods(@RequestBody GoodsEntity entity) {
        Page<TGoodsExample> queryPage = new Page<>(entity.getPage(), entity.getSize());
        return PageUtil.getPageResult2(customerHomeService.listHotsGoods(queryPage, entity));
    }
}
